import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { User } from '@/app/core/model/user/user';
import { Observable, of } from 'rxjs';
import { listLazyRoutes } from '@angular/compiler/src/aot/lazy_routes';

@Injectable({
  providedIn: 'root'
})
export class SuerService {

  constructor(private http: HttpClient) { }

  login(){
    
  }


  getUserlist(num:number): Observable<{}>{
   
    const List: User[]=[
      { id: 11, name: 'Dr Nice' },
      { id: 12, name: 'Narco' },
      { id: 13, name: 'Bombasto' },
      { id: 14, name: 'Celeritas' },
      { id: 15, name: 'Magneta' },
      { id: 16, name: 'RubberMan' },
      { id: 17, name: 'Dynama' },
      { id: 18, name: 'Dr IQ' },
      { id: 19, name: 'Magma' },
      { id: 20, name: 'Tornado' }
    ];;
    let Arr=[];
    // this.http.get('http://mytest.com/users.php').subscribe(res=>{
    //   console.log('http数据',res);
    // },error=>{
    //   console.log(error)
    // });
    this.http.request('post', 'http://mytest.com/users.php', {params: {}, headers: {}}).subscribe(res=>{
        console.log('http数据111',res);
      },error=>{
          console.log(error)
      });
    


    List.forEach((item,index)=>{
      console.log(item,index);
      if(index<num){
       Arr.push(item);
      }
    });

    const query = {
      code: 122,
      status: 1,
      message: 1,
      result: 1,
      data: 1
    };

    return  of(Arr);//;this.http.request('post', 'http://mytest.com/users.php', {params: {}, headers: {}});
  }

}
